import 'package:flutter/material.dart';
import 'package:untitled/services/world_time.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
// 加载动画
class Loading extends StatefulWidget {
  const Loading({Key? key}) : super(key: key);

  @override
  State<Loading> createState() => _LoadingState();
}

class _LoadingState extends State<Loading> {
  String time = 'loading';
  void setupWorldTime() async{
    WorldTime initState = WorldTime(location: "北京",flag: "China.png",url:'Asia/Shanghai'); // 实例化 类
    await initState.getData(); // 等待执行完毕
    // 拿到值
    print(initState.time);
    // 状态更新
    // setState(() {
    //   time = initState.time!;
    // });
    // 页面跳转 传参
    Navigator.pushNamed(context, "/home",arguments: {
      'location':initState.location,
      'flag':initState.flag,
      'time':initState.time,
      'isDayTime':initState.isDaytime,
    });
  }
  
  @override
  void initState() {
    super.initState();
    setupWorldTime();
    //print("initState function ran");
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue[900],
      body:Center(
        child: SpinKitHourGlass(
              color: Colors.white,
              size: 50.0,
        ),
      )
    );
    
  }
}